import 'package:flutter/material.dart';
import 'home_page/view/home_view.dart';
import 'mine/controller/mine_page.dart';

enum MainTagType { home, qa, mine }

extension MainTagTypeExt on MainTagType {
  IconData get icon {
    switch (this) {
      case MainTagType.home:
        return Icons.home;
      case MainTagType.qa:
        return Icons.question_answer;
      case MainTagType.mine:
        return Icons.person;
    }
  }

  String get title {
    switch (this) {
      case MainTagType.home:
        return "首页";
      case MainTagType.qa:
        return "问答";
      case MainTagType.mine:
        return "我的";
    }
  }

  Widget get page {
    switch (this) {
      case MainTagType.home:
        return const HomePageRoute();
      case MainTagType.qa:
        return const MinePageRoute();
      case MainTagType.mine:
        return const MinePageRoute();
    }
  }

  static List<BottomNavigationBarItem> get items {
    return MainTagType.values
        .map(
          (type) => BottomNavigationBarItem(
            icon: Icon(type.icon),
            label: type.title,
          ),
        )
        .toList();
  }
}
